<!DOCTYPE html>
<html>
<head>
    <title>Physics Diagram Fig. 5.10</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
        canvas {
            border: 1px solid #ccc;
            background-color: #fff;
        }
    </style>
</head>
<body>
    <canvas id="physicsCanvas" width="600" height="450"></canvas>
    <script>
        const canvas = document.getElementById('physicsCanvas');
        const ctx = canvas.getContext('2d');

        // Style settings to mimic the hand-drawn look
        ctx.strokeStyle = 'black';
        ctx.fillStyle = 'black';
        ctx.lineWidth = 2.5;
        ctx.lineCap = 'round'; // Makes line ends smoother

        const origin = { x: 250, y: 300 };

        // Helper function to draw an arrow
        function drawArrow(fromX, fromY, toX, toY, headLength = 12) {
            const dx = toX - fromX;
            const dy = toY - fromY;
            const angle = Math.atan2(dy, dx);

            ctx.beginPath();
            ctx.moveTo(fromX, fromY);
            ctx.lineTo(toX, toY);
            
            // Arrowhead
            ctx.moveTo(toX, toY);
            ctx.lineTo(toX - headLength * Math.cos(angle - Math.PI / 6), toY - headLength * Math.sin(angle - Math.PI / 6));
            ctx.moveTo(toX, toY);
            ctx.lineTo(toX - headLength * Math.cos(angle + Math.PI / 6), toY - headLength * Math.sin(angle + Math.PI / 6));
            
            ctx.stroke();
        }

        // Draw coordinate axes
        // Z-axis (horizontal)
        drawArrow(origin.x - 200, origin.y, origin.x + 230, origin.y);
        // X-axis (vertical)
        drawArrow(origin.x, origin.y + 100, origin.x, origin.y - 250);
        // Y-axis (diagonal)
        drawArrow(origin.x + 100, origin.y - 50, origin.x - 170, origin.y + 85);

        // Draw points P and Q
        const pointRadius = 4;
        // Point P on the x-axis
        const p_y = origin.y - 120;
        ctx.beginPath();
        ctx.arc(origin.x, p_y, pointRadius, 0, 2 * Math.PI);
        ctx.fill();
        // Point Q on the z-axis
        const q_x = origin.x + 150;
        ctx.beginPath();
        ctx.arc(q_x, origin.y, pointRadius, 0, 2 * Math.PI);
        ctx.fill();

        // Add labels
        ctx.font = 'italic 24px serif';
        // Axis labels
        ctx.fillText('x', origin.x + 10, origin.y - 235);
        ctx.fillText('z', origin.x + 235, origin.y + 5);
        ctx.fillText('y', origin.x - 190, origin.y + 100);
        
        // Point labels
        ctx.font = '24px serif';
        ctx.fillText('P', origin.x - 30, p_y + 8);
        ctx.fillText('Q', q_x - 8, origin.y - 15);

        // Distance labels
        ctx.font = 'italic 24px serif';
        ctx.fillText('b', origin.x + 10, (origin.y + p_y) / 2 + 10);
        ctx.fillText('vt', (origin.x + q_x) / 2 - 10, origin.y + 30);
        
        // Velocity vector v
        const v_arrow_start_x = origin.x + 260;
        const v_arrow_end_x = v_arrow_start_x + 50;
        drawArrow(v_arrow_start_x, origin.y, v_arrow_end_x, origin.y);
        ctx.fillText('v', v_arrow_end_x + 10, origin.y + 8);

        // Figure caption
        ctx.font = 'bold 20px serif';
        ctx.textAlign = 'center';
        ctx.fillText('Fig. 5.10', canvas.width / 2, 430);

    </script>
</body>
</html>